<?php

namespace app\common\model;

use think\Model;

class Cost extends Model
{
    //获取配置
    public function getinfo($type = 0)
    {
        $info = $this->where('Id', 1)->find();
        if ($type == 0) {
            return $info;
        }
        if ($type == 1) { //只获取注册赠送金额
            return $info['reg_to'];
        }
        if ($type == 2) { //只获取开通vip赠送金额
            return $info['open_vip_to'];
        }
        if ($type == 5) { //只获取开通页面信息
            return $info['vip_price'];
        }
        if ($type == 6) { //只获取是否开启短信验证码
            return $info['reg_phone'];
        }
    }
    //更新配置
    public function upinfo($info)
    {
        if ($this->isUpdate(true)->save($info, ['Id' => 1])) {
            return true;
        }
        return false;
    }


}
